<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
  <title>供应单列表</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link href="${server}/static/css/bootstrap.min.css" rel="stylesheet">
	<link href="${server}/static/css/bootstrap_new.css" rel="stylesheet">
	<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
	<script type="text/javascript"  src="${server}/static/js/bootstrap.min.js"></script>
	<script type="text/javascript"  src="${server}/static/js/bootstrap_new.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$(".status-menu").find("a").on("click",function(){
				var status = $(this).attr("value");
				var page = 1;
				var url = '${server}/quotation/list?status='+status+'&page='+page+' #quotation-box';
				$("#quotation-box").load(url);
				$(".status-menu").find("li").removeClass("active");
				$(this).parent().addClass("active");
			});
		});
		
		function toPage(page){
			var status = $("input[id='status']").val();
			var url = '${server}/quotation/list?status='+status+'&page='+page+' #quotation-box';
			$("#quotation-box").load(url);
		}
		function merchandiselist(quotationId){
			window.location.href="${server}/quotationmerchandise/list/"+quotationId+"/-1";
		}
		function reviewMerchandiselist(quotationId){
			window.location.href="${server}/merchandise/list/"+quotationId+"/-1";
		}
		function orderlist(quotationId){
			window.location.href="${server}/quotationorder/list/"+quotationId;
		}
		function deleteQuotation(quotationId){
			if(confirm("确定要删除吗？")){
			var url = "${server}/quotation/delete/"+quotationId;
			$.post(url,function(result){
				if(result != "YYK-10000"){
					alert("删除失败！")
					return;
				}
				var status = $("#status").val();
				var page = $("#page").val();
				var url = '${server}/quotation/list?status='+status+'&page='+page+' #quotation-box';
				$("#quotation-box").load(url);
			});
			}
		}
	</script>
</head>
<body data-spy="scroll" data-target=".navbar" data-offset="50">

<%@include file="../common/header.jsp"%>

<div id="myTabContent" class="tab-content">
   <div class="tab-pane fade in active" id="home">
		<form action="" id="pagerForm"  method="post">
			<div class="container">
				<ul class="navtip status-menu">
					<li class="active"><a href="javascript:;" value='0'>全部</a></li>
					<li><a href="javascript:;" value='1'">未处理</a></li>
					<li><a href="javascript:;" value='2'">已筛选</a></li>
					<li><a href="javascript:;" value='3'">待审核</a></li>
					<li><a href="javascript:;" value='4'">已发布</a></li>
					<li><a href="javascript:;" value='5'">已下单</a></li>
					<li><a href="javascript:;" value='6'">已失效</a></li>
					<li class="pull-right">
						<button type="button" class="btn btn-default btn-sm " onclick="window.location.href='${server}/quotation/add'">新建</button>
						<button type="button" class="btn btn-default btn-sm" onclick="window.location.href='${server}/summary/list'">汇总</button></li>
				</ul>
				</br> 
				<div id="quotation-box">
					<input type="hidden" id="page" value="${pageBean.page}"/>
					<input type="hidden" id="status" value="${status}"/>
					<table class="table table-bordered table-hover  table-striped" contenteditable="true">
						<thead>
							<tr>
								<th>Date</th>
								<th>List Name</th>
								<th>Brand</th>
								<th>Description</th>
								<th>Discount (%off)</th>
								<th>Priority</th>
								<th>Owner</th>
								<th>Status-初筛</th>
								<th>Status-数据</th>
								<th>定价系数（折上折在此基础上打95折）</th>
								<th>定价策略</th>
								<th>有效状态</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<c:if test="${empty pageBean.result}">
								<tr>
									<td colspan="13">暂无供应单信息</td>
								</tr>
							</c:if>
							<c:if test="${not empty pageBean.result}">
								<c:forEach items="${pageBean.result}" var="quotationDto">
									<tr>
										<td>
											<fmt:formatDate value="${quotationDto.quotation.quotationTime}" type="both"/>
										</td>
										<td onclick="merchandiselist('${quotationDto.quotation.quotationId}');"><a href="javascript:;">${quotationDto.quotation.quotationName}</a></td>
										<td>
											<c:forEach items="${quotationDto.quotationBrandList}" var="quotationBrand" varStatus="i">
												<c:if test="${i.index > 0}">,</c:if>
												${quotationBrand.brandId}
											</c:forEach>
										</td>
										<td>${quotationDto.quotation.quotationDesc}</td>
										<td>
											<fmt:formatNumber value="${quotationDto.quotation.quotationDiscount}" type="PERCENT"/>
										</td>
										<td></td>
										<td></td>
										<td></td>
										<td></td>
										<td></td>
										<td></td>
										<td>
											<c:choose>
												<c:when test="${quotationDto.quotation.quotationStatus eq 1}">未处理</c:when>
												<c:when test="${quotationDto.quotation.quotationStatus eq 2}">已筛选</c:when>
												<c:when test="${quotationDto.quotation.quotationStatus eq 3}">待审核</c:when>
												<c:when test="${quotationDto.quotation.quotationStatus eq 4}">已发布</c:when>
												<c:when test="${quotationDto.quotation.quotationStatus eq 5}">已下单</c:when>
												<c:when test="${quotationDto.quotation.quotationStatus eq 6}">已失效</c:when>
											</c:choose>
										</td>
										<td>
											<a href="javascript:;" onclick="reviewMerchandiselist('${quotationDto.quotation.quotationId}');">审核</a>
											<a href="javascript:;" onclick="orderlist('${quotationDto.quotation.quotationId}');">下单</a>
											<c:if test="${quotationDto.quotation.quotationStatus eq 1}">
												<a href="javascript:;" onclick="deleteQuotation('${quotationDto.quotation.quotationId}');">删除</a>
											</c:if>
										</td>
									</tr>
								</c:forEach>
							</c:if>
						</tbody>
						
						
					</table>
						<%@include file="../common/paging.jsp"%>
				</div>
			</div>
		</form>
   </div>
</div>


</body>
</html>
